
  $(document).ready(function(){
	  $('#comboxSearchfieldName').combobox({
			url: BASE_URL_FIELD_SEARCH + '/findAllOfCurrentUserCanManage' + '?v=' + Math.random(),
			valueField: 'id',
		    textField: 'name',
		    editable: false,
		    method:'get',
		    loadFilter: function(data){
		    	var allCheck = {'id':'','name':'全部'};
		    	data.content.unshift(allCheck);
		    	return data.content;
		    },
		    onSelect: function(record){
				
				if(record.id !== '')
				{
					comboxSearchSystemName.combobox({
					  disabled: false,
					  method:'get',
					  queryParams: {fieldId: record.id},
					  url: BASE_URL_FIELD_SYSTEM_SEARCH +'/findByFieldOfCurrentUserCanManage' + '?v=' + Math.random(),
					  valueField: 'id',
					  textField: 'name',
					  data:'',
					loadFilter: function(data){
						var allCheck = {'id':'','name':'全部'};
						data.content.unshift(allCheck);
						return data.content;
					},
					onLoadSuccess:function(){
						comboxSearchSystemName.combobox('setValue','');
					}
				  }).load();
				}else
				{
					comboxSearchSystemName.combobox({
					  disabled: true,
					  editable: false				  
					});
				}
		    },
		    onLoadSuccess:function(){
		    	$('#comboxSearchSystemName').combobox('setValue','');
		    }
		});
		
		//所属系统下拉框
		var comboxSearchSystemName = $('#comboxSearchSystemName').combobox({
        disabled: true,
        valueField: 'id',
        textField: 'name',
        editable: false,
		  data:[{id:'',name:'全部','selected':'true'}]
    });
	
	$("#forwardingName").combobox({
		url: BASE_URL_DATA_DICTIONARY_VALUE_SEARCH +'/findByTypeCode?typeCode=20019' + '&v=' + Math.random(),
		valueField: 'valueCode',
	    textField: 'valueName',
	    editable:false,
	    method:'get',
	    loadFilter: function(data){
	    	var allCheck = {'valueCode':'','valueName':'全部'};
	    	data.unshift(allCheck);
	    	return data;
	    }

		
//	valueField: 'id',
//	textField: 'name',
//	editable: false,
//	data:[{id:'',name:'全部',selected:'true'},{id:'',name:'等待转发'},{id:'',name:'正在转发'},{id:'',name:'转发成功 '},{id:'',name:'转发失败 '}]
//		//formatter: {id:'1',name:'全部',id:'',name:'等待转发',id:'',name:'正在转发',id:'',name:'转发成功 ',id:'',name:'转发失败'};
	});
	
	function serviceLogExport() {
		var portsName = $('#txtSearchInterfaceName').val();
		var stemName = $('#comboxSearchSystemName').combobox('getValue');
		var reqResult = $('#comboxSearchfieldName').combobox('getValue');
		var wardingName = $("#forwardingName").combobox('getValue');
		var data = '{"portsName":"' + portsName + '","reqResult":"' + reqResult + '" ,'
				+ '"stemName":"' + stemName + '","wardingName":"'
				+ wardingName + '"}';

		location.href = BASE_URL_API + '/processQuer/serviceLogExport?portsName='
				+ portsName + '&reqResult=' + reqResult + '&stemName='
				+ stemName + '&wardingName=' + wardingName;
	};
	
	
	  $("#datagrid").datagrid({
		  	url : BASE_URL_STORE_FORWARD_SEARCH+"/findByExample",
			method:'get',
			autoRowHeight:true,
			nowrap:false,
			pageSize:20,
			singleSelect:true,
			striped:true,
			pageList:[10,20,50,100],
			pagination:true,
			columns:[[
						{field:'fieldName',title:'领域',width:100},
						{field:'fieldSystemName',title:'系统',width:100},
						{field:'interfaceName',title:'接口名称',width:180},
						{field:'forwardDate',title:'发生时间',width:120},
						{field:'statusForDisplay',title:'状态',width:120}
			      ]],
			      loadFilter:function(data){
						return {
							total: data.totalElements,
							rows: data.content
						};
					},
			onBeforeLoad:function(param){
				param.page -= 1;
				param.size = param.rows;
				delete param.rows;
				
//				param.sort = 'createTime,desc';
//				param.name = $('#txtSearch').val();
				
				var field = $("#comboxSearchfieldName").combobox("getValue");
				if(field!=""){
					param.fieldId = field;
				}
				var system = $("#comboxSearchSystemName").combobox("getValue");
				if(system!=""){
					param.systemId = system;
				}			
				var interfaceName = $("#txtSearchInterfaceName").val();
				if(interfaceName!=""){
					param.ifName = interfaceName;
				}
				var status =$("#forwardingName").combobox("getValue");
				if(status!=""){
					param.status = status;
				}
				 
			}
		});

	  	$("#datagrid").datagrid('getPager').pagination({   
		    displayMsg:'当前显示从 [{from}] 到 [{to}] 共[{total}]条记录'
		});
		
});
  
  function search(){
		$("#datagrid").datagrid("reload", BASE_URL_STORE_FORWARD_SEARCH+"/findByExample");

	}
 
 	
 	
  
	